package org.fle4y.common.constants.common;

import java.math.BigDecimal;
import java.text.DecimalFormat;

/**
 * author : xiehui<br>
 * company : northking <br>
 * Create at: 2012-5-31
 * @version : 1.0<br>
 *
 *  Description : 定义一些金融的常量
 */
public class MoneyConstant {
	/**
	 * 定义money的转换格式##0.00.
	 */
	private static final String CURRENT_FORMAT_TWO = "##0.00";

	/**
	 * 定义money的转换格式##,##0.00.
	 */
	private static final String CURRENT_FORMAT_FORE = "##0.0000";

	/**
	 * 定义money的转换格式###,###,##0.00.
	 */
	private static final String CURRENT_FORMAT_COMMA = "###,###,##0.00";

	/**
	 * 定义money的转换格式#(整数).
	 */
	private static final String CURRENT_FORMAT_INT = "#";

	/**
	 * 定义数字的转换格式000x.
	 */
	private static final String ORMID = "0000";
	
	/**
	 * money转换成##0.00的格式.
	 * 
	 * @param current
	 *            当传入参数为BigDecimal时

	 * @return String
	 */
	public static String currentFormateTwo(BigDecimal current) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(CURRENT_FORMAT_TWO);

		String formateCur = doubleFormat.format(current);

		return formateCur;
	}

	/**
	 * money转换成##0.00的格式.
	 * 
	 * @param current
	 *            当传入参数为int时

	 * @return String
	 */
	public static String currentFormateTwo(int current) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(CURRENT_FORMAT_TWO);

		String formateCur = doubleFormat.format(current);

		return formateCur;
	}

 
	/**
	 * money转换成##0.00的格式.
	 * 
	 * @param current
	 *            当传入参数为float时

	 * @return String
	 */
	public static String currentFormateTwo(float current) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(CURRENT_FORMAT_TWO);

		String formateCur = doubleFormat.format(current);

		return formateCur;
	}

	/**
	 * money转换成##0.00的格式.
	 * 
	 * @param current
	 *            当传入参数为double时

	 * @return String
	 */
	public static String currentFormateTwo(double current) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(CURRENT_FORMAT_TWO);

		String formateCur = doubleFormat.format(current);

		return formateCur;
	}

	/**
	 * 转换成00000N的格式.
	 * 
	 * @param number
	 *            当传入参数为double时

	 * @return String
	 */
	public static String currentFormateORM(double number) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(ORMID);

		String formateCur = doubleFormat.format(number);

		return formateCur;
	}

	/**
	 * money转换成##0.00的格式.
	 * 
	 * @param current
	 *            当传入参数为String时

	 * @return String
	 */
	public static String currentFormateTwo(String current) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(CURRENT_FORMAT_TWO);

		BigDecimal bdCurrent = new BigDecimal(current);
		String formateCur = doubleFormat.format(bdCurrent);

		return formateCur;
	}

	/**
	 * money转换成##0.0000的格式.
	 * 
	 * @param current
	 *            当传入参数为BigDecimal时

	 * @return String
	 */
	public static String currentFormateFour(BigDecimal current) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(CURRENT_FORMAT_FORE);

		String formateCur = doubleFormat.format(current);

		return formateCur;
	}

	/**
	 * money转换成##0.0000的格式.
	 * 
	 * @param current
	 *            当传入参数为int时

	 * @return String
	 */
	public static String currentFormateFour(int current) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(CURRENT_FORMAT_FORE);

		String formateCur = doubleFormat.format(current);

		return formateCur;
	}

	/**
	 * money转换成##0.0000的格式.
	 * 
	 * @param current
	 *            当传入参数为float时

	 * @return String
	 */
	public static String currentFormateFour(float current) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(CURRENT_FORMAT_FORE);

		String formateCur = doubleFormat.format(current);

		return formateCur;
	}

	/**
	 * money转换成##0.0000的格式.
	 * 
	 * @param current
	 *            当传入参数为double时

	 * @return String
	 */
	public static String currentFormateFour(double current) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(CURRENT_FORMAT_FORE);

		String formateCur = doubleFormat.format(current);

		return formateCur;
	}

	/**
	 * money转换成##0.0000的格式.
	 * 
	 * @param current
	 *            当传入参数为String时

	 * @return String
	 */
	public static String currentFormateFour(String current) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(CURRENT_FORMAT_FORE);

		BigDecimal bdCurrent = new BigDecimal(current);
		String formateCur = doubleFormat.format(bdCurrent);

		return formateCur;
	}

	/**
	 * money转换成整数的格式.
	 * 
	 * @param current
	 *            当传入参数为BigDecimal时

	 * @return String
	 */
	public static String currentFormateInt(BigDecimal current) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(CURRENT_FORMAT_INT);

		String formateCur = doubleFormat.format(current);

		return formateCur;
	}

	/**
	 * money转换成整数的格式.
	 * 
	 * @param current
	 *            当传入参数为int时

	 * @return String
	 */
	public static String currentFormateInt(int current) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(CURRENT_FORMAT_INT);

		String formateCur = doubleFormat.format(current);

		return formateCur;
	}

	/**
	 * money转换成整数的格式.
	 * 
	 * @param current
	 *            当传入参数为float时

	 * @return String
	 */
	public static String currentFormateInt(float current) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(CURRENT_FORMAT_INT);

		String formateCur = doubleFormat.format(current);

		return formateCur;
	}

	/**
	 * money转换成###,###,##0.00格式.
	 * 
	 * @param current
	 *            当传入参数为BigDecimal时

	 * @return String
	 */
	public static String currentFormateComma(BigDecimal current) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(CURRENT_FORMAT_COMMA);

		String formateCur = doubleFormat.format(current);

		return formateCur;
	}
	
	/**
	 * money转换成##0.00的格式.
	 * 
	 * @param current
	 *            当传入参数为double时

	 * @return String
	 */
	public static String currentFormateComma(double current) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(CURRENT_FORMAT_COMMA);

		String formateCur = doubleFormat.format(current);

		return formateCur;
	}

	/**
	 * money转换成整数的格式.
	 * 
	 * @param current
	 *            当传入参数为double时

	 * @return String
	 */
	public static String currentFormateInt(double current) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(CURRENT_FORMAT_INT);

		String formateCur = doubleFormat.format(current);

		return formateCur;
	}

	/**
	 * money转换成整数的格式.
	 * 
	 * @param current
	 *            当传入参数为String时

	 * @return String
	 */
	public static String currentFormateInt(String current) {
		DecimalFormat doubleFormat = new DecimalFormat();
		doubleFormat.applyPattern(CURRENT_FORMAT_INT);

		BigDecimal bdCurrent = new BigDecimal(current);
		String formateCur = doubleFormat.format(bdCurrent);

		return formateCur;
	}
}
